/*
 * AddEx.cpp
 *
 *  Created on: Aug 7, 2011
 *      Author: dino
 */

#include "AddEx.h"

AddEx::AddEx(Expression* leftOperand, Expression* rightOperand) {
	addOperand(leftOperand);
	addOperand(rightOperand);
}

AddEx::~AddEx() {
}

bool AddEx::simplify() {
	bool shouldAdd = true;
	Expression* leftOperand = getOperand(0);
	Expression* rightOperand = getOperand(1);
	if (!simplifyOperands()) {
		Expression* result = leftOperand->add(rightOperand);
		this->parent->replaceOperand(this, result);
	}
	return true;
}

void AddEx::toString(ostream& out) {
	Expression* leftOperand = getOperand(0);
	Expression* rightOperand = getOperand(1);
	out<<"(";
	leftOperand->toString(out);
	out<<"+";
	rightOperand->toString(out);
	out<<")";
}
